package com.java1234.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import com.java1234.dao.ManagerDao;
import com.java1234.util.DButil;

import javax.swing.JLabel;
import javax.swing.JTextField;

public class Managerfrm extends JFrame {

	private JPanel contentPane;
	private JTextField managername;
	private JTextField managertel;
	private JTextField managerid;
	private JTextField manageremail;
	private Connection c=null;
	private DButil db=new DButil();
	private ManagerDao mdao=new ManagerDao();

	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Managerfrm frame = new Managerfrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}*/

	/**
	 * Create the frame.
	 */
	public Managerfrm(String mname) {
		String mno,name,mtel,memail;
		setTitle("\u7BA1\u7406\u5458\u4FE1\u606F");
		setBounds(100, 100, 325, 160);
		this.setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(null);
		setContentPane(contentPane);
		
		JLabel lblNewLabel = new JLabel("\u59D3\u540D\uFF1A");
		lblNewLabel.setBounds(10, 36, 54, 15);
		contentPane.add(lblNewLabel);
		
		JLabel label = new JLabel("\u7F16\u53F7\uFF1A");
		label.setBounds(164, 36, 54, 15);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u7535\u8BDD\uFF1A");
		label_1.setBounds(10, 82, 54, 15);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("\u90AE\u7BB1\uFF1A");
		label_2.setBounds(164, 82, 54, 15);
		contentPane.add(label_2);
		
		managername = new JTextField();
		managername.setEditable(false);
		managername.setBounds(46, 33, 82, 21);
		contentPane.add(managername);
		managername.setColumns(10);
		
		managertel = new JTextField();
		managertel.setEditable(false);
		managertel.setBounds(46, 79, 82, 21);
		contentPane.add(managertel);
		managertel.setColumns(10);
		
		managerid = new JTextField();
		managerid.setEditable(false);
		managerid.setBounds(203, 33, 98, 21);
		contentPane.add(managerid);
		managerid.setColumns(10);
		
		manageremail = new JTextField();
		manageremail.setEditable(false);
		manageremail.setBounds(203, 79, 98, 21);
		contentPane.add(manageremail);
		manageremail.setColumns(10);
		try {
			c=db.getcon();
			ResultSet rs=mdao.searchmanager(c, mname);
			while(rs.next())
			{
				name=rs.getString("mname");
				mno=rs.getString("mno");
				mtel=rs.getString("mtel");
				memail=rs.getString("memail");
				managername.setText(name);
				managerid.setText(mno);
				managertel.setText(mtel);
				manageremail.setText(memail);
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally
		{
			if(c!=null)
				try {
					c.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		}
		
	}
}
